package com.yanqu.road.server.logic.thread.client.msg.push.task;

import com.yanqu.road.server.helper.SignHelper;
import com.yanqu.road.server.manger.AppKeyMgr;
import com.yanqu.road.utils.executor.GeneralTask;
import com.yanqu.road.utils.http.HttpHelper;

import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * @Author wpj
 * @Date 2021/3/21
 */
public class ClientMsgPushTask extends GeneralTask {

    private String title;
    private String text;
    private String target;
    private String audience;
    private String clickType;
    private String url;
    private String intent;
    private String extension;
    private int gameId;


    @Override
    public void doRun() {

        SortedMap<String, String> paramMap = new TreeMap<>();
//        paramMap.put("title",);
//        paramMap.put("text", );
//        paramMap.put("target",);
//        paramMap.put("audience");
//        paramMap.put("click_type");
//        paramMap.put("url");
//        paramMap.put("intent");
//        paramMap.put("extension");
        String sign = SignHelper.getSign(paramMap, AppKeyMgr.getAndroidAppSecret());
        paramMap.put("sign", sign);
        try {
            String url = AppKeyMgr.getPlatformBaseUrl() + "/msg/sendAppMsg/" + AppKeyMgr.getAndroidAppId() + "/" + AppKeyMgr.getPlatformChannelId();
            getLOGGER().info("sendAppMsg url:{}", url);
            Map<String, String> resultMap = HttpHelper.doGet(url, paramMap);
            getLOGGER().info("sendAppMsg code:{}, body:{}", resultMap.get("code"), resultMap.get("body"));
        } catch (Exception e) {
            getLOGGER().error("sendAppMsg error:",e);
        }

    }
}
